﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;


using PowerCreator.LMS.Common;
//using PowerCreator.LMS.Logic.Common;
using PowerCreator.LMS.Web.Paper;
using PowerCreator.LMS.Web.Question;
using PowerCreator.LMS.Paper.Entiry;
using PowerCreator.LMS.Question.Entiry;
using PowerCreator.LMS.Common.Utils;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.ViewQuery;

public partial class sysadmin_PaperManager_ReadTestPaper : PowerCreator.LMS.Web.Base.BasePage
{
    const string NEWTEXT = "<input id={0} name={0}  type=\"text\" Class=\"myline\" value=\"{1}\" />";
    string QEUSTIONINDEX = "";


    ManagerPaper objManagerPaper = new ManagerPaper();
    ManagerQuestion objManagerQuestion = new ManagerQuestion();


    public string ispanduancz = "0";
    public string isdancz = "0";
    public string isgaiz = "0";
    public string isduocz = "0";
    public string istiancz = "0";
    public string isyuecz = "0";
    public string iswantcz = "0";
    public string iswangcz = "0";
    public string iscaocz = "0";
    public string iszuocz = "0";
    public int thi = 1;
    public int Question_tk_ID = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        QEUSTIONINDEX = "<span class=\"font_bule\">【" + GetLanageValueByKey("theme_Paper_Msg1", PowerCreator.LMS.Language.LanagetItemType.Page) + "{0}" + GetLanageValueByKey("theme_Paper_Msg2", PowerCreator.LMS.Language.LanagetItemType.Page) + "】</span>";
        if (!IsPostBack)
        {
            ViewState["PaperID"] = Request.QueryString["PaperID"].ToString();
            ViewState["UserID"] = Request.QueryString["UserID"].ToString();
            ViewState["ProjectID"] = Request.QueryString["ProjectID"].ToString();
            ViewState["ClassID"] = Request.QueryString["ClassID"].ToString();


            ViewState["CourseID"] = Request.QueryString["CourseID"].ToString();
            ViewState["ProjectResourceID"] = Request.QueryString["ProjectResourceID"].ToString();
            ViewState["CourseResourceID"] = Request.QueryString["CourseResourceID"].ToString();

            PageLoad();
            Band_dlst_panduan();//判断
            BindDLti1();//单选

            BindDLti2();//多选

            BindDLti3();//填空
            BindDLti4();//名词解释
            BindDLti5();//简答
            //BindDL_zuhe();//组合题

            InitPage();

        }
    }

    protected override void InitPage()
    {
        lab_PaperNameTitle.Text = GetLanageValueByKey("lab_EditUserPaper_PaperName", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_UserNameTitle.Text = GetLanageValueByKey("lab_EditUserPaper_UserName", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_PaperScoreTitle.Text = GetLanageValueByKey("lab_EditUserPaper_PaperScore", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_RealScore.Text = GetLanageValueByKey("lab_EditUserPaper_RealScore", PowerCreator.LMS.Language.LanagetItemType.Page);

        lab_Panduan.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Panduanti", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_Danxuan.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Danxuanti", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_Duoxuan.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Duoxuanti", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_Tiankong.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Tiankongti", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_Mingcijieshi.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Mingcijieshiti", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_Jiandati.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Jiandati", PowerCreator.LMS.Language.LanagetItemType.Page);
       // lab_Zuheti.Text = GetLanageValueByKey("lab_EditUserPaper_Question_Zuheti", PowerCreator.LMS.Language.LanagetItemType.Page);

        btn_submit.Text = GetLanageValueByKey("btn_EditUserPaper_Submit", PowerCreator.LMS.Language.LanagetItemType.Page);
        base.InitPage();
    }

    private void PageLoad()
    {
        string str = "PaperID=" + ViewState["PaperID"].ToString();
        DataTable dt = new DataTable();
        dt = objManagerPaper.QueryPaper(str);

        PowerCreator.LMS.Web.User.User objUserInfo = new PowerCreator.LMS.Web.User.User();
        int UserID = int.Parse(ViewState["UserID"].ToString());
        int UserType = objUserInfo.LoadUser(UserID).UserType;
        if (UserType == 0)
        {
            lab_UserName.Text = objUserInfo.LoadStudentByUserID(UserID).StudentName;
        }
        else
        {
            lab_UserName.Text = objUserInfo.LoadTteacherByUserID(UserID).TeacherName;
        }

        if (dt.Rows.Count > 0)
        {
            ViewState["PaperSelectType"] = dt.Rows[0]["PaperSelectType"].ToString();
            lab_PaperName.Text = dt.Rows[0]["PaperName"].ToString();
            lab_SumScore.Text = dt.Rows[0]["PaperScore"].ToString();
        }
        //ManagerSecurityUserInfo objuserinfologic = new ManagerSecurityUserInfo();
        //string cmd = "UserID=" + ViewState["UserID"].ToString();
        //lab_UserName.Text = objuserinfologic.Query(cmd).Rows[0]["UserName"].ToString();
    }
    #region 判断题生成代码

    private void Band_dlst_panduan()
    {

        string search = "  and Question.QuestionClass<>3 and Question.FKQuestionTypeID=1 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_panduan.Visible = false;
            return;
        }
        dlst_panduanti.DataSource = dt;
        dlst_panduanti.DataKeyField = "PUanswerID";
        dlst_panduanti.DataBind();
    }
    protected void dlst_panduanti_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        string PUAID = dlst_panduanti.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBtx = (Label)e.Item.FindControl("LBtx");

            Label LBsm1 = (Label)e.Item.FindControl("LBsm1");
            RadioButtonList answerList1 = (RadioButtonList)e.Item.FindControl("AnswerList1");
            if (answerList1 != null)
            {
                LBsm1.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

                thi = thi + 1;
                BindAnswerList(answerList1, QuestionID, LBsm1);
                Label LBdantiid = (Label)e.Item.FindControl("LBdantiid");  //取得题目id
                LBdantiid.Text = QuestionID;
            }

            Label LBdanra = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBdanra.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值

            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            if (lab_useranswer.Text == LBdanra.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }
    }
    #endregion

    #region Web 单选题生成代码
    private void BindDLti1()
    {

        string search = "  and Question.QuestionClass<>3 and Question.FKQuestionTypeID=2 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_danxuan.Visible = false;
            return;
        }
        DLti1.DataSource = dt;
        DLti1.DataKeyField = "PUanswerID";
        DLti1.DataBind();
    }
    protected void DLti1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        string PUAID = DLti1.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBtx = (Label)e.Item.FindControl("LBtx");

            Label LBsm1 = (Label)e.Item.FindControl("LBsm1");
            RadioButtonList answerList1 = (RadioButtonList)e.Item.FindControl("AnswerList1");
            if (answerList1 != null)
            {
                LBsm1.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

                thi = thi + 1;
                BindAnswerList(answerList1, QuestionID, LBsm1);
                Label LBdantiid = (Label)e.Item.FindControl("LBdantiid");  //取得题目id
                LBdantiid.Text = QuestionID;
            }

            Label LBdanra = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBdanra.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值


            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();




            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            if (lab_useranswer.Text == LBdanra.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }
    }
    #endregion

    #region 绑定单选按钮答案

    /// <summary>
    /// 绑定单选按钮答案

    /// </summary>
    /// <param name="radioList">单选按钮集合</param>
    /// <param name="tiid">题目ID</param>
    private void BindAnswerList(RadioButtonList radioList, string QuestionID, Label lab_kongjian)
    {
        string str = " FKQuestionOptionQuestionID =" + QuestionID;
        DataTable dt = objManagerQuestion.QueryQuestionOption(str);
        radioList.DataSource = dt;
        radioList.DataTextField = "QuestionOptionContent";//答案
        radioList.DataValueField = "QuestionOptionID";//标题
        radioList.DataBind();
        ArrayList objlist = new ArrayList();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            radioList.Items[i].Text = radioList.Items[i].Text;
        }
    }

    #endregion

    #region Web 多选题生成代码
    private void BindDLti2()
    {
        string search = "  and Question.QuestionClass<>3 and Question.FKQuestionTypeID=3 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_duoxuan.Visible = false;
            return;
        }
        DLti2.DataSource = dt;
        DLti2.DataKeyField = "PUanswerID";
        DLti2.DataBind();

    }

    public void DLti2_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
    {
        string PUAID = DLti2.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            CheckBoxList CheckList2 = (CheckBoxList)e.Item.FindControl("CheckList2");
            if (CheckList2 != null)
            {
                Label LBsm2 = (Label)e.Item.FindControl("LBsm2");

                LBsm2.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;
                thi = thi + 1;
                BindCheckList(CheckList2, QuestionID, LBsm2);
                Label LBduotiid = (Label)e.Item.FindControl("LBduotiid");  //取得题目id
                LBduotiid.Text = QuestionID;
            }


            Label LBduora = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBduora.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim().Replace("$", "");

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值


            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }

            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");//用户答案
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString().Replace("$", "");

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            if (lab_useranswer.Text == LBduora.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }
    }
    #endregion

    #region 绑定多选筐答案
    /// <summary>
    /// 绑定多选筐答案
    /// </summary>
    /// <param name="checkList"> 多选筐列表</param>
    /// <param name="tiid">题目ID</param>
    private void BindCheckList(CheckBoxList checkList, string QuestionID, Label lab_kongjian)
    {
        string str = " FKQuestionOptionQuestionID =" + QuestionID;
        DataTable dt = objManagerQuestion.QueryQuestionOption(str);
        checkList.DataSource = dt;
        checkList.DataTextField = "QuestionOptionContent";//答案
        checkList.DataValueField = "QuestionOptionID";//标题
        checkList.DataBind();
        ArrayList objlist = new ArrayList();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            checkList.Items[i].Text = checkList.Items[i].Text;
        }

    }

    #endregion

    #region Web 填空题生成代码

    private void BindDLti3()
    {
        string search = "  and Question.QuestionClass<>3 and Question.FKQuestionTypeID=4 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_tiankong.Visible = false;
            return;
        }
        ViewState["Question_tk_Count"] = dt.Rows.Count;
        DataTable dt_question_tk = new DataTable();
        dt_question_tk.Columns.Add("kong_count");
        string[] row = new string[1];
        row[0] = "0";
        dt_question_tk.Rows.Add(row);
        ViewState["dt_Question_tk"] = dt_question_tk;
        DLti3.DataSource = dt;
        DLti3.DataKeyField = "PUanswerID";
        DLti3.DataBind();
    }

    public void DLti3_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
    {
        string PUAID = DLti3.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字


            string[] UserAnswer_list = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString().Trim().Split('$');//用户答案

            StringBuilder newQuestionContent = new StringBuilder();

            string[] str_QuestionContent = QuestionContent.Trim().Split('_');

            DataTable dt_question_tk = (DataTable)ViewState["dt_Question_tk"];
            dt_question_tk.Columns.Add("kong_count" + Question_tk_ID.ToString());

            dt_question_tk.Rows[0]["kong_count" + Question_tk_ID.ToString()] = str_QuestionContent.Length - 1;
            ViewState["dt_Question_tk"] = dt_question_tk;

            for (int i = 0; i < str_QuestionContent.Length; i++)
            {
                string txtvalue = "";
                if (i < UserAnswer_list.Length)
                {
                    if (UserAnswer_list[i] != null)
                    {
                        txtvalue = UserAnswer_list[i].ToString();
                        string textID = string.Format(NEWTEXT, "newtext_" + Question_tk_ID.ToString() + "_" + i.ToString(), UserAnswer_list[i].ToString());
                        newQuestionContent.Append(str_QuestionContent[i] + textID);
                    }
                    else
                    {
                        newQuestionContent.Append(str_QuestionContent[i]);
                    }
                }
                else
                {
                    newQuestionContent.Append(str_QuestionContent[i]);
                }



            }
            Question_tk_ID += 1;



            Label LBsmtk = (Label)e.Item.FindControl("LBsmtk");  //取得题目说明

            LBsmtk.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + newQuestionContent.ToString();

            thi = thi + 1;


            Label LBtkra = (Label)e.Item.FindControl("LBtkra");     //取得题目答案
            LBtkra.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label LBduora = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBduora.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值
            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分

            if (lab_useranswer.Text == LBduora.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }
    }
    #endregion

    #region 名词解释
    private void BindDLti4()
    {
        string search = "  and Question.QuestionClass<>3 and Question.FKQuestionTypeID=5 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_mingcijieshi.Visible = false;
            return;
        }
        DLti4.DataSource = dt;
        DLti4.DataKeyField = "PUanswerID";
        DLti4.DataBind();
    }

    public void DLti4_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
    {
        string PUAID = DLti4.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBjdftiid = (Label)e.Item.FindControl("LBjdftiid");  //取得题目id
            LBjdftiid.Text = QuestionID;

            Label LBsmjdf = (Label)e.Item.FindControl("LBsmjdf");  //取得题目说明

            LBsmjdf.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

            thi = thi + 1;

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值

            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            //FreeTextBoxControls.FreeTextBox txt_UserAnswer = (FreeTextBoxControls.FreeTextBox)e.Item.FindControl("txt_UserAnswer");
            //txt_UserAnswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();
            FredCK.FCKeditorV2.FCKeditor txt_UserAnswer = (FredCK.FCKeditorV2.FCKeditor)e.Item.FindControl("txtQuestionContent");
            txt_UserAnswer.Value = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            txt_Score.Text = "0";
        }
    }
    #endregion

    #region Web 简答

    private void BindDLti5()
    {
        string search = "  and Question.QuestionClass<>3 and Question.FKQuestionTypeID=6 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_jiandati.Visible = false;
            return;
        }
        DLti5.DataSource = dt;
        DLti5.DataKeyField = "PUanswerID";
        DLti5.DataBind();
    }

    public void DLti5_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
    {
        string PUAID = DLti5.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {

            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBjdftiid = (Label)e.Item.FindControl("LBjdftiid");  //取得题目id
            LBjdftiid.Text = QuestionID;

            Label LBsmjdf = (Label)e.Item.FindControl("LBsmjdf");  //取得题目说明

            LBsmjdf.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

            thi = thi + 1;

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值

            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            FredCK.FCKeditorV2.FCKeditor txt_UserAnswer = (FredCK.FCKeditorV2.FCKeditor)e.Item.FindControl("txtQuestionContent");
            txt_UserAnswer.Value = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();


            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            txt_Score.Text = "0";
        }
    }
    #endregion

    #region  组合题

    private void BindDL_zuhe()
    {
        string search = " and Question.FKQuestionTypeID=7 and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString() + " and FKPUanswerCourseID=" + ViewState["CourseID"].ToString();
        DataTable dt = objManagerPaper.GetPaperUserAnswerInfo(search);
        if (dt.Rows.Count == 0)
        {
            pn_zuhe.Visible = false;
            return;
        }
        dlst_zuhe.DataSource = dt;
        dlst_zuhe.DataKeyField = "PUanswerID";
        dlst_zuhe.DataBind();

    }

    public void dlst_zuhe_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
    {
        string PUAID = dlst_zuhe.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {

            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBjdftiid = (Label)e.Item.FindControl("LBjdftiid");  //取得题目id
            LBjdftiid.Text = QuestionID;

            Label LBsmjdf = (Label)e.Item.FindControl("LBsmjdf");  //取得题目说明

            LBsmjdf.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

            thi = thi + 1;

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值
            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            //Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            //lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            //TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            //txt_Score.Text = "0";

            #region 获得子题目的DataTable

            string QuestionItem = dt.Rows[0]["QuestionItemList"].ToString();

            string[] QuestionItemList = QuestionItem.Split('$');

            #region 获取子题目的ID集合
            ArrayList Question_danxList = new ArrayList();
            ArrayList Question_pandList = new ArrayList(); ;
            ArrayList Question_duoxList = new ArrayList();
            ArrayList Question_tiankList = new ArrayList();
            ArrayList Question_jiand = new ArrayList();

            for (int i = 0; i < QuestionItemList.Length; i++)
            {
                switch (objManagerQuestion.LoadQuestion(int.Parse(QuestionItemList[i].ToString())).FKQuestionTypeID)
                {
                    case 1:
                        Question_pandList.Add(QuestionItemList[i].ToString());
                        break;
                    case 2:
                        Question_danxList.Add(QuestionItemList[i].ToString());
                        break;
                    case 3:
                        Question_duoxList.Add(QuestionItemList[i].ToString());
                        break;
                    case 4:
                        Question_tiankList.Add(QuestionItemList[i].ToString());
                        break;
                    default:
                        Question_jiand.Add(QuestionItemList[i].ToString());
                        break;

                }
            }
            #endregion

            #region 获取判断题DataTable
            StringBuilder strSearch_pand = new StringBuilder();
            strSearch_pand.Append("  and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString());
            strSearch_pand.Append(" and QuestionID in(-1");

            for (int i = 0; i < Question_pandList.Count; i++)
            {
                if (i == Question_pandList.Count - 1)
                {
                    strSearch_pand.Append("," + Question_pandList[i].ToString() + ")");
                }
                else
                {
                    strSearch_pand.Append("," + Question_pandList[i].ToString());
                }
            }

            DataTable dt_Question_pand = objManagerPaper.GetPaperUserAnswerInfo(strSearch_pand.ToString());

            #endregion

            #region 获取单选题DataTable

            StringBuilder strSearch_danx = new StringBuilder();
            strSearch_danx.Append("  and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString());
            strSearch_danx.Append(" and QuestionID in(-1");

            for (int i = 0; i < Question_danxList.Count; i++)
            {
                if (i == Question_danxList.Count - 1)
                {
                    strSearch_danx.Append("," + Question_danxList[i].ToString() + ")");
                }
                else
                {
                    strSearch_danx.Append("," + Question_danxList[i].ToString());
                }
            }

            DataTable dt_Question_danx = objManagerPaper.GetPaperUserAnswerInfo(strSearch_danx.ToString());

            #endregion

            #region 获取多选题DataTable

            StringBuilder strSearch_duox = new StringBuilder();
            strSearch_duox.Append("  and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString());
            strSearch_duox.Append(" and QuestionID in(-1");

            for (int i = 0; i < Question_duoxList.Count; i++)
            {
                if (i == Question_duoxList.Count - 1)
                {
                    strSearch_duox.Append("," + Question_duoxList[i].ToString() + ")");
                }
                else
                {
                    strSearch_duox.Append("," + Question_duoxList[i].ToString());
                }
            }

            DataTable dt_Question_duox = objManagerPaper.GetPaperUserAnswerInfo(strSearch_duox.ToString());

            #endregion

            #region 获取填空题DataTable

            //StringBuilder strSearch_tiank = new StringBuilder();
            //strSearch_tiank.Append("  and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString());
            //strSearch_tiank.Append(" and QuestionID in(-1");

            //for (int i = 0; i < Question_tiankList.Count; i++)
            //{
            //    if (i == Question_tiankList.Count - 1)
            //    {
            //        strSearch_tiank.Append("," + Question_tiankList[i].ToString() + ")");
            //    }
            //    else
            //    {
            //        strSearch_tiank.Append("," + Question_tiankList[i].ToString());
            //    }
            //}

            //DataTable dt_Question_tiank = objManagerPaper.GetPaperUserAnswerInfo(strSearch_tiank.ToString());

            #endregion

            #region 获取简答题DataTable

            StringBuilder strSearch_jianda = new StringBuilder();
            strSearch_jianda.Append("  and  PUanswerUserID=" + ViewState["UserID"].ToString() + " and FKPUanswerProjectID=" + ViewState["ProjectID"].ToString() + " and PUanswerClassID=" + ViewState["ClassID"].ToString() + " and FKPUanswerPaperID=" + ViewState["PaperID"].ToString());
            strSearch_jianda.Append(" and QuestionID in(-1");

            for (int i = 0; i < Question_jiand.Count; i++)
            {
                if (i == Question_jiand.Count - 1)
                {
                    strSearch_jianda.Append("," + Question_jiand[i].ToString() + ")");
                }
                else
                {
                    strSearch_jianda.Append("," + Question_jiand[i].ToString());
                }
            }

            DataTable dt_Question_jianda = objManagerPaper.GetPaperUserAnswerInfo(strSearch_jianda.ToString());

            #endregion


            #endregion

            Control container = e.Item;
            ListItemType itemType = e.Item.ItemType;

            if (itemType == ListItemType.Item || itemType == ListItemType.Footer || itemType == ListItemType.AlternatingItem)
            {
                if (e.Item.DataItem == null)
                {
                    return;
                }

                #region 绑定判断题

                DataList dlst_zuhe_panduanti = (DataList)container.FindControl("dlst_zuhe_panduanti");
                Panel objPanel_panduanti = (Panel)container.FindControl("pn_panduanti");

                if (null != dlst_zuhe_panduanti)
                {
                    if (dt_Question_pand.Rows.Count != 0)
                    {
                        dlst_zuhe_panduanti.ItemDataBound += new DataListItemEventHandler(dlst_zuhe_panduanti_ItemDataBound);

                        dlst_zuhe_panduanti.DataSource = dt_Question_pand;
                        dlst_zuhe_panduanti.DataKeyField = "PUanswerID";
                        dlst_zuhe_panduanti.DataBind();
                    }
                    else
                    {
                        objPanel_panduanti.Visible = false;
                    }

                }
                #endregion

                #region 绑定单选题

                DataList dlst_zuhe_danxuanti = (DataList)container.FindControl("dlst_zuhe_danxuanti");
                Panel objPanel_danxuanti = (Panel)container.FindControl("pn_danxuanti");

                if (null != dlst_zuhe_danxuanti)
                {
                    if (dt_Question_danx.Rows.Count != 0)
                    {
                        dlst_zuhe_danxuanti.ItemDataBound += new DataListItemEventHandler(dlst_zuhe_danxuanti_ItemDataBound);

                        dlst_zuhe_danxuanti.DataSource = dt_Question_danx;
                        dlst_zuhe_danxuanti.DataKeyField = "PUanswerID";
                        dlst_zuhe_danxuanti.DataBind();
                    }
                    else
                    {
                        objPanel_danxuanti.Visible = false;
                    }

                }
                #endregion

                #region 绑定多选题

                DataList dlst_zuhe_duoxuanti = (DataList)container.FindControl("dlst_zuhe_duoxuanti");
                Panel objPanel_duoxuanti = (Panel)container.FindControl("pn_duoxuanti");

                if (null != dlst_zuhe_duoxuanti)
                {
                    if (dt_Question_duox.Rows.Count != 0)
                    {
                        dlst_zuhe_duoxuanti.ItemDataBound += new DataListItemEventHandler(dlst_zuhe_duoxuanti_ItemDataBound);

                        dlst_zuhe_duoxuanti.DataSource = dt_Question_duox;
                        dlst_zuhe_duoxuanti.DataKeyField = "PUanswerID";
                        dlst_zuhe_duoxuanti.DataBind();
                    }
                    else
                    {
                        objPanel_duoxuanti.Visible = false;
                    }

                }
                #endregion

                #region 绑定填空题

                //DataList dlst_zuhe_tiankongti = (DataList)container.FindControl("dlst_zuhe_tiankongti");
                //Panel objPanel_tiankongti = (Panel)container.FindControl("pn_tiankongti");

                //if (null != dlst_zuhe_tiankongti)
                //{
                //    if (dt_Question_tiank.Rows.Count != 0)
                //    {
                //        dlst_zuhe_tiankongti.ItemDataBound += new DataListItemEventHandler(dlst_zuhe_tiankongti_ItemDataBound);

                //        dlst_zuhe_tiankongti.DataSource = dt_Question_tiank;
                //        dlst_zuhe_tiankongti.DataKeyField = "PUanswerID";
                //        dlst_zuhe_tiankongti.DataBind();
                //    }
                //    else
                //    {
                //        objPanel_tiankongti.Visible = false;
                //    }

                //}
                #endregion

                #region 绑定简答题（主观题，问答题类型）

                DataList dlst_zuhe_jiandati = (DataList)container.FindControl("dlst_zuhe_jiandati");
                Panel objPanel_jiandati = (Panel)container.FindControl("pn_jiandati");

                if (null != dlst_zuhe_jiandati)
                {
                    if (dt_Question_jianda.Rows.Count != 0)
                    {
                        dlst_zuhe_jiandati.ItemDataBound += new DataListItemEventHandler(dlst_zuhe_jiandati_ItemDataBound);

                        dlst_zuhe_jiandati.DataSource = dt_Question_jianda;
                        dlst_zuhe_jiandati.DataKeyField = "PUanswerID";
                        dlst_zuhe_jiandati.DataBind();
                    }
                    else
                    {
                        objPanel_jiandati.Visible = false;
                    }

                }
                #endregion

            }
        }
    }
    #endregion

    protected void dlst_zuhe_panduanti_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        DataList dlst = (DataList)e.Item.Parent;
        string PUAID = dlst.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBtx = (Label)e.Item.FindControl("LBtx");

            Label LBsm1 = (Label)e.Item.FindControl("LBsm1");
            RadioButtonList answerList1 = (RadioButtonList)e.Item.FindControl("AnswerList1");
            if (answerList1 != null)
            {
                LBsm1.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

                thi = thi + 1;
                BindAnswerList(answerList1, QuestionID, LBsm1);
                Label LBdantiid = (Label)e.Item.FindControl("LBdantiid");  //取得题目id
                LBdantiid.Text = QuestionID;
            }

            Label LBdanra = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBdanra.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值

            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            if (lab_useranswer.Text == LBdanra.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }
    }
    protected void dlst_zuhe_danxuanti_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        DataList dlst = (DataList)e.Item.Parent;

        string PUAID = dlst.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBtx = (Label)e.Item.FindControl("LBtx");

            Label LBsm1 = (Label)e.Item.FindControl("LBsm1");
            RadioButtonList answerList1 = (RadioButtonList)e.Item.FindControl("AnswerList1");
            if (answerList1 != null)
            {
                LBsm1.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

                thi = thi + 1;
                BindAnswerList(answerList1, QuestionID, LBsm1);
                Label LBdantiid = (Label)e.Item.FindControl("LBdantiid");  //取得题目id
                LBdantiid.Text = QuestionID;
            }

            Label LBdanra = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBdanra.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值


            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            if (lab_useranswer.Text == LBdanra.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }

    }
    protected void dlst_zuhe_duoxuanti_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        DataList dlst = (DataList)e.Item.Parent;

        string PUAID = dlst.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            CheckBoxList CheckList2 = (CheckBoxList)e.Item.FindControl("CheckList2");
            if (CheckList2 != null)
            {
                Label LBsm2 = (Label)e.Item.FindControl("LBsm2");

                LBsm2.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;
                thi = thi + 1;
                BindCheckList(CheckList2, QuestionID, LBsm2);
                Label LBduotiid = (Label)e.Item.FindControl("LBduotiid");  //取得题目id
                LBduotiid.Text = QuestionID;
            }


            Label LBduora = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBduora.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim().Replace("$", "");

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值


            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }

            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");//用户答案
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString().Replace("$", "");

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            if (lab_useranswer.Text == LBduora.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }
        }
    }
    protected void dlst_zuhe_tiankongti_ItemDataBound(object sender, DataListItemEventArgs e)
    {

        DataList dlst = (DataList)e.Item.Parent;

        string PUAID = dlst.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {

            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字


            string[] UserAnswer_list = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString().Trim().Split('$');//用户答案

            StringBuilder newQuestionContent = new StringBuilder();

            string[] str_QuestionContent = QuestionContent.Split('_');

            DataTable dt_question_tk = (DataTable)ViewState["dt_Question_tk"];
            dt_question_tk.Columns.Add("kong_count" + Question_tk_ID.ToString());

            dt_question_tk.Rows[0]["kong_count" + Question_tk_ID.ToString()] = str_QuestionContent.Length - 1;
            ViewState["dt_Question_tk"] = dt_question_tk;

            for (int i = 0; i < str_QuestionContent.Length; i++)
            {
                string txtvalue = "";
                if (i < UserAnswer_list.Length)
                {
                    if (UserAnswer_list[i] != null)
                    {
                        txtvalue = UserAnswer_list[i].ToString();
                        string textID = string.Format(NEWTEXT, "newtext_" + Question_tk_ID.ToString() + "_" + i.ToString(), UserAnswer_list[i].ToString());
                        newQuestionContent.Append(str_QuestionContent[i] + textID);
                    }
                    else
                    {
                        newQuestionContent.Append(str_QuestionContent[i]);
                    }
                }
                else
                {
                    newQuestionContent.Append(str_QuestionContent[i]);
                }



            }
            Question_tk_ID += 1;



            Label LBsmtk = (Label)e.Item.FindControl("LBsmtk");  //取得题目说明

            LBsmtk.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

            thi = thi + 1;


            Label LBtkra = (Label)e.Item.FindControl("LBtkra");     //取得题目答案
            LBtkra.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label LBduora = (Label)e.Item.FindControl("LBdanra");    //取得题目正确答案
            LBduora.Text = dt.Rows[0]["QuestionAnswer"].ToString().Trim();

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值
            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分

            if (lab_useranswer.Text == LBduora.Text)
            {
                txt_Score.Text = lab_Score.Text;
            }
            else
            {
                txt_Score.Text = "0";
            }

        }

    }
    protected void dlst_zuhe_jiandati_ItemDataBound(object sender, DataListItemEventArgs e)
    {

        DataList dlst = (DataList)e.Item.Parent;
        string PUAID = dlst.DataKeys[e.Item.ItemIndex].ToString().Trim();
        Label lab_PUAID = (Label)e.Item.FindControl("lab_PUAID");
        lab_PUAID.Text = PUAID;
        DataTable dt_UserAnswerinfo = objManagerPaper.QueryPaperUserAnswer("PUanswerID=" + PUAID + "");
        if (dt_UserAnswerinfo.Rows.Count > 0)
        {
            string QuestionID = dt_UserAnswerinfo.Rows[0]["FKPUanswerQuestionID"].ToString();//获取题号
            string str = " QuestionID=" + QuestionID;
            DataTable dt = objManagerQuestion.QueryQuestion(str);//根据题号从题库获取列表

            string QuestionContent = dt.Rows[0]["QuestionContent"].ToString();//获取问题名字

            Label LBjdftiid = (Label)e.Item.FindControl("LBjdftiid");  //取得题目id
            LBjdftiid.Text = QuestionID;

            Label LBsmjdf = (Label)e.Item.FindControl("LBsmjdf");  //取得题目说明

            LBsmjdf.Text = string.Format(QEUSTIONINDEX, thi.ToString()) + QuestionContent;

            thi = thi + 1;

            Label lab_Score = (Label)e.Item.FindControl("lab_Score");    //取得题目分数值

            if (ViewState["PaperSelectType"].ToString() == "2")//如果是随机试卷
            {

                string search = "FKPaperQuePloyPaperID=" + ViewState["PaperID"].ToString() + " and FKPaperQuePloyProjectID=" + ViewState["ProjectID"].ToString() + " and FKPaperQuePloyClassID=" + ViewState["ClassID"].ToString() + " and FKPaperQuePloyQuestionID=" + QuestionID + " and FKPaperQuePloyUserID=" + ViewState["UserID"].ToString() + " and FKPaperQuePloyCourseID=" + ViewState["CourseID"].ToString();
                lab_Score.Text = objManagerPaper.QueryPaperQuestionPloy(search).Rows[0]["PaperQuePloyScore"].ToString();
            }
            else
            {
                lab_Score.Text = dt.Rows[0]["QuestionDefaultScore"].ToString().Trim();
            }


            Label lab_useranswer = (Label)e.Item.FindControl("lab_useranswer");
            lab_useranswer.Text = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();

            FredCK.FCKeditorV2.FCKeditor txt_UserAnswer = (FredCK.FCKeditorV2.FCKeditor)e.Item.FindControl("txtQuestionContent");
            txt_UserAnswer.Value = dt_UserAnswerinfo.Rows[0]["PUanswerUserAnswer"].ToString();


            TextBox txt_Score = (TextBox)e.Item.FindControl("txt_Score");//用户得分
            txt_Score.Text = "0";
        }
    }


    protected void btn_submit_Click(object sender, EventArgs e)
    {
        int sumcount = 0;

        #region 提交判断题

        foreach (DataListItem oDataListItem in dlst_panduanti.Items)
        {

            Label lab_PUAID = (Label)oDataListItem.FindControl("lab_PUAID");

            VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            TextBox txt_score = (TextBox)oDataListItem.FindControl("txt_Score");
            TextBox txt_Comment = (TextBox)oDataListItem.FindControl("txt_Comment");

            if (txt_score.Text.Trim() != "")
            {
                if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;

                }
                Label lab_score = (Label)oDataListItem.FindControl("lab_Score");
                if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg2", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                sumcount += int.Parse(txt_score.Text.Trim());
                objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            }
            else
            {
                Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                return;
            }


        }
        #endregion

        #region 提交单选题
        foreach (DataListItem oDataListItem in DLti1.Items)
        {

            Label lab_PUAID = (Label)oDataListItem.FindControl("lab_PUAID");

            VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            TextBox txt_score = (TextBox)oDataListItem.FindControl("txt_Score");
            TextBox txt_Comment = (TextBox)oDataListItem.FindControl("txt_Comment");

            if (txt_score.Text.Trim() != "")
            {
                if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;

                }
                Label lab_score = (Label)oDataListItem.FindControl("lab_Score");
                if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg4", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                sumcount += int.Parse(txt_score.Text.Trim());
                objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            }
            else
            {
                Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                return;
            }


        }
        #endregion

        #region 提交多选题
        foreach (DataListItem pDataListItem in DLti2.Items)
        {
            Label lab_PUAID = (Label)pDataListItem.FindControl("lab_PUAID");

            VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            TextBox txt_score = (TextBox)pDataListItem.FindControl("txt_Score");
            TextBox txt_Comment = (TextBox)pDataListItem.FindControl("txt_Comment");
            if (txt_score.Text.Trim() != "")
            {
                if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;


                }
                Label lab_score = (Label)pDataListItem.FindControl("lab_Score");
                if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg5", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                sumcount += int.Parse(txt_score.Text.Trim());
                objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            }
            else
            {
                Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                return;
            }
        }
        #endregion

        #region 提交填空题

        foreach (DataListItem qDataListItem in DLti3.Items)
        {
            Label lab_PUAID = (Label)qDataListItem.FindControl("lab_PUAID");

            VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            TextBox txt_score = (TextBox)qDataListItem.FindControl("txt_Score");
            TextBox txt_Comment = (TextBox)qDataListItem.FindControl("txt_Comment");
            if (txt_score.Text.Trim() != "")
            {
                if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                Label lab_score = (Label)qDataListItem.FindControl("lab_Score");
                if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg6", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                sumcount += int.Parse(txt_score.Text.Trim());
                objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            }
            else
            {
                Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                return;
            }
        }
        #endregion

        #region 名词解析
        foreach (DataListItem rDataListItem in DLti4.Items)
        {
            Label lab_PUAID = (Label)rDataListItem.FindControl("lab_PUAID");

            VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            TextBox txt_score = (TextBox)rDataListItem.FindControl("txt_Score");
            TextBox txt_Comment = (TextBox)rDataListItem.FindControl("txt_Comment");

            //FreeTextBoxControls.FreeTextBox txt_UserAnswer = (FreeTextBoxControls.FreeTextBox)rDataListItem.FindControl("txt_UserAnswer");
            FredCK.FCKeditorV2.FCKeditor txt_UserAnswer = (FredCK.FCKeditorV2.FCKeditor)rDataListItem.FindControl("txtQuestionContent");

            if (txt_score.Text.Trim() != "")
            {
                if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                Label lab_score = (Label)rDataListItem.FindControl("lab_Score");
                if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg7", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                sumcount += int.Parse(txt_score.Text.Trim());
                objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                objpaperuseranswerinfo.PUanswerUserAnswer = txt_UserAnswer.Value;
                objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            }
            else
            {
                Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                return;
            }

        }
        #endregion

        #region 提交简单题
        foreach (DataListItem tDataListItem in DLti5.Items)
        {
            Label lab_PUAID = (Label)tDataListItem.FindControl("lab_PUAID");

            VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            TextBox txt_score = (TextBox)tDataListItem.FindControl("txt_Score");
            TextBox txt_Comment = (TextBox)tDataListItem.FindControl("txt_Comment");
            FredCK.FCKeditorV2.FCKeditor txt_UserAnswer = (FredCK.FCKeditorV2.FCKeditor)tDataListItem.FindControl("txtQuestionContent");
            
            if (txt_score.Text.Trim() != "")
            {
                if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                Label lab_score = (Label)tDataListItem.FindControl("lab_Score");
                if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg8", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
                sumcount += int.Parse(txt_score.Text.Trim());
                objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                objpaperuseranswerinfo.PUanswerUserAnswer = txt_UserAnswer.Value;
                objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            }
            else
            {
                Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                return;
            }


        }

        #endregion

        #region   提交组合题
        foreach (DataListItem zuheti_DataListItem in dlst_zuhe.Items)
        {
            #region 提交组合判断题
            DataList dlst_panduanti_zuheti = (DataList)zuheti_DataListItem.FindControl("dlst_zuhe_panduanti");
            foreach (DataListItem oDataListItem in dlst_panduanti_zuheti.Items)
            {

                Label lab_PUAID = (Label)oDataListItem.FindControl("lab_PUAID");

                VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

                objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
                TextBox txt_score = (TextBox)oDataListItem.FindControl("txt_Score");
                TextBox txt_Comment = (TextBox)oDataListItem.FindControl("txt_Comment");

                if (txt_score.Text.Trim() != "")
                {
                    if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;

                    }
                    Label lab_score = (Label)oDataListItem.FindControl("lab_Score");
                    if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg9", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;
                    }
                    sumcount += int.Parse(txt_score.Text.Trim());
                    objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                    objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                    objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
                }
                else
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }


            }
            #endregion

            #region 提交组合单选题
            DataList dlst_danxuanti = (DataList)zuheti_DataListItem.FindControl("dlst_zuhe_danxuanti");
            foreach (DataListItem oDataListItem in dlst_danxuanti.Items)
            {

                Label lab_PUAID = (Label)oDataListItem.FindControl("lab_PUAID");

                VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

                objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
                TextBox txt_score = (TextBox)oDataListItem.FindControl("txt_Score");
                TextBox txt_Comment = (TextBox)oDataListItem.FindControl("txt_Comment");

                if (txt_score.Text.Trim() != "")
                {
                    if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;

                    }
                    Label lab_score = (Label)oDataListItem.FindControl("lab_Score");
                    if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg9", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;
                    }
                    sumcount += int.Parse(txt_score.Text.Trim());
                    objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                    objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                    objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
                }
                else
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }


            }
            #endregion

            #region 提交组合多选题

            DataList dlst_duoxuanti = (DataList)zuheti_DataListItem.FindControl("dlst_zuhe_duoxuanti");
            foreach (DataListItem pDataListItem in dlst_duoxuanti.Items)
            {
                Label lab_PUAID = (Label)pDataListItem.FindControl("lab_PUAID");

                VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

                objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
                TextBox txt_score = (TextBox)pDataListItem.FindControl("txt_Score");
                TextBox txt_Comment = (TextBox)pDataListItem.FindControl("txt_Comment");
                if (txt_score.Text.Trim() != "")
                {
                    if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;


                    }
                    Label lab_score = (Label)pDataListItem.FindControl("lab_Score");
                    if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg9", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;
                    }
                    sumcount += int.Parse(txt_score.Text.Trim());
                    objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                    objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                    objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
                }
                else
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }
            }
            #endregion

            #region 提交组合填空题
            //DataList dlst_tiankongti = (DataList)zuheti_DataListItem.FindControl("dlst_zuhe_tiankongti");
            //foreach (DataListItem qDataListItem in dlst_tiankongti.Items)
            //{
            //    Label lab_PUAID = (Label)qDataListItem.FindControl("lab_PUAID");

            //    VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

            //    objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
            //    TextBox txt_score = (TextBox)qDataListItem.FindControl("txt_Score");
            //    TextBox txt_Comment = (TextBox)qDataListItem.FindControl("txt_Comment");
            //    if (txt_score.Text.Trim() != "")
            //    {
            //        if (!PageValidate.IsNumber(txt_score.Text.Trim()))
            //        {
            //            Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
            //            return;
            //        }
            //        Label lab_score = (Label)qDataListItem.FindControl("lab_Score");
            //        if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
            //        {
            //            Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg9", PowerCreator.LMS.Language.LanagetItemType.Page));
            //            return;
            //        }
            //        sumcount += int.Parse(txt_score.Text.Trim());
            //        objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
            //        objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
            //        objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
            //    }
            //    else
            //    {
            //        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
            //        return;
            //    }
            //}
            #endregion

            #region 提交组合简单题
            DataList dlst_jiandati = (DataList)zuheti_DataListItem.FindControl("dlst_zuhe_jiandati");
            foreach (DataListItem tDataListItem in dlst_jiandati.Items)
            {
                Label lab_PUAID = (Label)tDataListItem.FindControl("lab_PUAID");

                VOPaperUserAnswer objpaperuseranswerinfo = new VOPaperUserAnswer();

                objpaperuseranswerinfo = objManagerPaper.LoadPaperUserAnswer(int.Parse(lab_PUAID.Text.ToString()));
                TextBox txt_score = (TextBox)tDataListItem.FindControl("txt_Score");
                TextBox txt_Comment = (TextBox)tDataListItem.FindControl("txt_Comment");
                FredCK.FCKeditorV2.FCKeditor txt_UserAnswer = (FredCK.FCKeditorV2.FCKeditor)tDataListItem.FindControl("txtQuestionContent");
                if (txt_score.Text.Trim() != "")
                {
                    if (!PageValidate.IsNumber(txt_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg1", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;
                    }
                    Label lab_score = (Label)tDataListItem.FindControl("lab_Score");
                    if (int.Parse(txt_score.Text.Trim()) > int.Parse(lab_score.Text.Trim()))
                    {
                        Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg9", PowerCreator.LMS.Language.LanagetItemType.Page));
                        return;
                    }
                    sumcount += int.Parse(txt_score.Text.Trim());
                    objpaperuseranswerinfo.PUanswerScore = int.Parse(txt_score.Text.ToString());
                    objpaperuseranswerinfo.PUanswerComment = txt_Comment.Text;
                    objpaperuseranswerinfo.PUanswerUserAnswer = txt_UserAnswer.Value;
                    objManagerPaper.UpdatePaperUserAnswer(objpaperuseranswerinfo);
                }
                else
                {
                    Script.Alert(this, "msg", GetLanageValueByKey("AddPaper_msg3", PowerCreator.LMS.Language.LanagetItemType.Page));
                    return;
                }


            }

            #endregion
        }
        #endregion

        #region 更新用户考试相关信息

        int userID = int.Parse(ViewState["UserID"].ToString());
        int paperID = int.Parse(ViewState["PaperID"].ToString());
        //int classID = int.Parse(ViewState["ClassID"].ToString());
        //int projectID = int.Parse(ViewState["ProjectID"].ToString());
        PowerCreator.LMS.Web.CreatedByInfo cinfo = GetCreatedByInfo();
        int readPeoperID = cinfo.UserID;

        int paperScore = sumcount;


        VOUserPaperHistory objUserPaperHistoryInfo = new VOUserPaperHistory();

        DataTable dt = objManagerPaper.QueryUserPaperHistory(" FKUPHistoryUserID=" + userID + " and FKUPHistoryPaperID=" + paperID + " and UPHistoryReadState=0 and UPHistoryScore=0 and UPHistoryIsPass=0 and FKUPHistoryCourseID=" + ViewState["CourseID"].ToString());

        if (dt.Rows.Count > 0)
        {
            int UPHID = int.Parse(dt.Rows[0]["UPHistoryID"].ToString());
            objUserPaperHistoryInfo = objManagerPaper.LoadUserPaperHistory(UPHID);
            objUserPaperHistoryInfo.UPHistoryReadState = 1;
            objUserPaperHistoryInfo.UPHistoryScore = sumcount;
            objUserPaperHistoryInfo.UPHistoryReadTime = DateTime.Now;
            objUserPaperHistoryInfo.UPHistoryReadUserID = readPeoperID;

            objManagerPaper.UpdateUserPaperHistory(objUserPaperHistoryInfo);
        }

        #endregion

        //Script.Alert(this, "msg", "提交成功");
        string url = "TestPaperUserList.aspx?";
        Script.ShowAndRedirect(Page, GetLanageValueByKey("AddPaper_msg12", PowerCreator.LMS.Language.LanagetItemType.Page), url);
    }
}
